#include "include.h"

#if BT_TWS_LTX_EN
static const uint8_t tws_inquiry_rf_param[7] = {
     7,     //captune
     5,     //pa_gain
     3,     //mix_gain
    18,     //dig_gain
     4,     //pa_bias
     0,     //vbko_add
     4,     //txdbm
};
#endif

const uint8_t *bt_rf_get_inq_param(void)
{
#if BT_TWS_LTX_EN
    return tws_inquiry_rf_param;
#else
    return NULL;
#endif
}

const uint8_t *bt_rf_get_param(void)
{
    if(xcfg_cb.bt_user_param_en) {
        return (const uint8_t *)&xcfg_cb.rf_tag0;
    }
    return NULL;
}

//调试时才打开，否则异常时无法复位
//void sys_error_hook_do(u8 err_no);
//AT(.com_text.err)
//void sys_error_hook(u8 err_no)
//{
//    sys_error_hook_do(err_no);
//}
#define PB1_PIN 1
//正常启动Main函数
int main(void)
{
	u16 cmt=0;
    printf("Hello AB536X: %08x\n", (LVDCON & 0x1ff0000));
	#if 0
	//GPIOBFEN &= ~BIT(PB1_PIN);
	//GPIOBDE|= BIT(PB1_PIN);
	//GPIOBDIR&= ~BIT(PB1_PIN);
	//GPIOBCLR= BIT(PB1_PIN);
	#if 1
	while(1)
	{
		WDT_CLR();
		delay_5ms(1);
		cmt++;
		printf("cmt:%d\n",cmt);
		if(cmt>2000)
		{
			break;
		}
		//GPIOBCLR= BIT(PB1_PIN);
	}
	#endif
	GPIOBFEN &= ~BIT(PB1_PIN);
	GPIOBDE|= BIT(PB1_PIN);
	GPIOBDIR&= ~BIT(PB1_PIN);
	GPIOBCLR= BIT(PB1_PIN);
	#endif
    bsp_sys_init();
    func_run();
    return 0;
}

//升级完成
void update_complete(int mode)
{
    bsp_update_init();
    if (mode == 0) {
        WDT_DIS();
        while (1);
    }
    WDT_RST();
}
